package com.bl.weilan.api.controller.tradepolicy;


import com.bl.weilan.api.controller.BaseController;
import com.bl.weilan.common.ApiResponseBody;
import com.bl.weilan.dao.model.ReportEntity;
import com.bl.weilan.dao.model.TradeChartEntity;
import com.bl.weilan.service.biz.trade.TradeService;
import com.bl.weilan.service.biz.tradepolicy.TradePolicyService;
import com.bl.weilan.service.vo.report.ReportListVo;
import com.bl.weilan.service.vo.tradeb.TradeBListVo;
import com.bl.weilan.service.vo.tradepolicy.TradePolicyListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Log4j2
@RequestMapping(value = {"/weilan/apis/trade_policy"})
@Api(value = "行业政策相关", description = "行业政策相关")
public class TradePolicyController extends BaseController {
    @Autowired
    TradePolicyService policyService;

    @ApiOperation(value = "根据行业id获取政策法规列表", notes = "根据行业id获取政策法规列表,按照时间排序，升序-asc/降序-desc")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "order", value = "升序-asc/降序-desc", required = true, paramType = "query", dataType = "String", defaultValue = "desc"),
            @ApiImplicitParam(name = "page", value = "页数", required = false, paramType = "query", dataType = "int", defaultValue = "1"),
            @ApiImplicitParam(name = "size", value = "每页大小", required = false, paramType = "query", dataType = "int", defaultValue = "10")})
    @GetMapping(value = {"/get_list"})
    public ApiResponseBody<TradePolicyListVo> gettradeBlist(
            @RequestParam(value = "id", required = false) String id,
            @RequestParam(value = "order", required = false, defaultValue = "desc") String order,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page,
            @RequestParam(value = "size", required = false, defaultValue = "10") int size,
            HttpServletRequest request) {

        Pageable pageable = new PageRequest(page - 1, size);

        TradePolicyListVo tradePolicyListVo = policyService.getList(id, order, pageable);

        return ApiResponseBody.createSuccessBody(tradePolicyListVo);
    }

//    @ApiOperation(value = "获取行业详细", notes = "获取行业详细")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "String")})
//    @GetMapping(value = {"/get_detail"})
//    public ApiResponseBody<ReportListVo> reportList(
//            @RequestParam(value = "id", required = true) String id,
//            HttpServletRequest request) {
//
//        TradeCEntity tradeCEntity = policyService.getDetail(id);
//
//        return ApiResponseBody.createSuccessBody(reportEntity);
//    }

}
